package ucd.smarthome.security;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

import ucd.smarthome.databaseinterface.User;
import ucd.smarthome.datastore.DatabaseImpl;

public class Activator implements BundleActivator {

	private static BundleContext context;
	private ServiceReference sr;

	static BundleContext getContext() {
		return context;
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;
		sr=context.getServiceReference(DatabaseImpl.class.getName());
		DatabaseImpl db=(DatabaseImpl)context.getService(sr);
		db.updateUser(new User("Daemoneye","123456",10,"13204073@ucdconnect.ie"));
		System.out.println("Good morning");
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext bundleContext) throws Exception {
		Activator.context = null;
		
	}

}
